package com.zwhu.nt;

import java.awt.Container;
import java.util.ArrayList;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.TableColumn;

public class frame2 extends JFrame{
	/**
	 * 弹出窗口显示信息函数
	 * @param t
	 */
	public frame2(ArrayList t) {
		Container cp= getContentPane();
		cp.setLayout(null);
		ArrayList al=t;
    	Note a=(Note)al.get(0);
    	int p=al.size();
    	String h=null;
    	h="通讯录中总共有"+p+"个人";
    	JOptionPane.showMessageDialog(null, h,"错误提示",JOptionPane.INFORMATION_MESSAGE);
        Object[] oj=al.toArray();
        String[][] myArray = new String[oj.length][7];
        
        for(int i=0;i<oj.length;i++){
    	   String[] q=oj[i].toString().split(",");
    	   for(int j=0;j<q.length;j++){
    		   myArray[i][j]=q[j];
    	   }
        }
        System.out.println(myArray[0][2]);
        JTable table=new JTable(myArray,new String[]
        {"num","name","zip","address","telephone","mobile","email"});
        TableColumn col=null;
        int cols=table.getColumnCount();
        
        for(int j=0;j<cols;j++){
        	col=table.getColumnModel().getColumn(j);
        	col.setPreferredWidth(100);
        }
        
        table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        JScrollPane scroll=new JScrollPane(table);
        scroll.setSize(600,400);
        cp.add(scroll);
	}
}
